<!DOCTYPE html>
<html lang="zh-CN">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>登陆</title>

		<!-- Bootstrap -->
		<link rel="stylesheet" href="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/css/bootstrap.css" />
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
			.class_div_loginbg {
				height: 100vh;
				background-image: url(../img/login.png);
				background-repeat: no-repeat;
				background-size: 100% 100%;
			}
			.class_div_loginbox {
				border-radius:5px;
				padding-top:40px;
				background:rgba(240, 242, 245,0.5);
				margin:20px;
				position: fixed;
				bottom:20%;
				right:26%;
				height:220px;
				width: 450px;
			}
			.class_h1_title {
				text-align: center;
			}
			.form-group{
				padding: 5px;
			}
		</style>
	</head>

	<body>
		<div class="class_div_loginbg" style="margin: 0px;padding: 0;">
			<div class="class_div_loginbox">
					<form class="form-horizontal" id='loginForm' name="loginForm" onsubmit="return false">
						<div class="form-group">
							<label for="inputEmail3" class="col-sm-2 col-sm-offset-1 control-label">账号：</label>
							<div class="col-sm-8">
								<input type="text" name="username" class="form-control" id="num" placeholder="请输入账号">
							</div>
						</div>
						<div class="form-group">
							<label for="inputPassword3" class="col-sm-2 col-sm-offset-1 control-label">密码：</label>
							<div class="col-sm-8">
								<input type="password" name="password" class="form-control" id="passwd" placeholder="请输入密码">
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-offset-4 col-sm-4">
								<button class="btn btn-danger" style="width:100%;text-align: center;" onclick="Login()">登陆</button>
							</div>
						</div>
					</form>
			</div>
		</div>
		<script type="text/javascript" src="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/jquery-3.3.1.js" ></script>
		<script type="text/javascript" src="../bootstrap-3.3.7-dist/bootstrap-3.3.7-dist/js/bootstrap.min.js" ></script>
		<script src="../js/ip.js"></script>
		<script type="text/javascript">
			function Login() {
					var ip = returnIp();
					var postaddress =ip+  '/login';
					$.ajax({
						//几个参数需要注意一下
						type: "POST", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						url: postaddress, //url
						data: $('form').serializeArray(),
						success: function(result) {
							if (result.code == 0)
							{
								localStorage.setItem('user', JSON.stringify(result.data));
								if(result.data.name == "admin")
									  window.location.href = 'Router.html';
								  else 
									  window.location.href = 'DaFenPage.html';
							}else{
								alert('账号密码错误！');
							}
						}, 
						error: function() {

						}
					});
				}
		</script>
	</body>

</html>